﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace WowGuildSite.Armory
{
    public class ArmoryBaseStatCollection : IEnumerable<ArmoryBaseStat>
    {
        private ArmoryCharacter             character;

        public ArmoryBaseStat               this[BaseStatType type]
        {
            get { return GetBaseStat(type); }
        }

        public ArmoryBaseStat               Strength
        {
            get
            {
                return GetBaseStat(BaseStatType.Strength);
            }
        }

        public ArmoryBaseStat               Agility
        {
            get
            {
                return GetBaseStat(BaseStatType.Agility);
            }
        }

        public ArmoryBaseStat               Stamina
        {
            get
            {
                return GetBaseStat(BaseStatType.Stamina);
            }
        }

        public ArmoryBaseStat               Intellect
        {
            get
            {
                return GetBaseStat(BaseStatType.Intellect);
            }
        }

        public ArmoryBaseStat               Spirit
        {
            get
            {
                return GetBaseStat(BaseStatType.Spirit);
            }
        }

        public ArmoryBaseStat               Armor
        {
            get
            {
                return GetBaseStat(BaseStatType.Armor);
            }
        }

        public IEnumerator<ArmoryBaseStat>  GetEnumerator()
        {
            Array values = Enum.GetValues(typeof(BaseStatType));

            foreach (BaseStatType t in values)
            {
                yield return GetBaseStat(t);
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        private  ArmoryBaseStat     GetBaseStat(BaseStatType type )
        {
            return ArmoryBaseStat.FromElement(character.SheetDocument.GetElement(String.Format("/page/characterInfo/characterTab/baseStats/{0}", type.ToString().ToLower())));
        }

        internal ArmoryBaseStatCollection( ArmoryCharacter character )
        {
            if (character == null)
            {
                throw new ArgumentNullException("character");
            }

            this.character = character;
        }
    }
}
